import {formDownload} from 'nc-lightapp-front';

export default function exportPsnInfo() {
    const {table, orgVal, show_on_job_psn, exportAllpks, exportType} = this.props;
    const {queryMode, targetKeys} = this.state;
    let psnjobPks = '';
    if (exportType === 'all') {
        psnjobPks = exportAllpks.join();
    } else {
        const checkedRows = this.props.table.getCheckedRows('ncc60071702list');
        if (checkedRows.length === 0) {
            psnjobPks = table.getClickRowIndex('ncc60071702list').record.pk_psnjob.value;
        } else {
            psnjobPks = checkedRows.map(item => item.data.values.pk_psnjob.value).join();
        }

    }
    let postData = {
        pk_org: orgVal.refpk,
        func_type: '3',
        queryMode,
        show_on_job_psn,
        psnjobPks,
        infosetPKs: targetKeys.join()
    };
    return formDownload({
        params: postData,
        url: '/nccloud/hrhi/psndoc/PsndocExportPsninfoDoAction.do',
        enctype: 2
    });
}
